#!/usr/bin/perl

# Perl script to help with finding clock divisors

my $lessthan = 1;		# Force computed frequency less than target 
my $base = 14745600;
my $target = 200000000;

my @r = ($target*2);

for (my $a = 2; $a < 33; ++$a) {
    for (my $b = 2; $b < 17; ++$b) {
	for (my $c = 2; $c < 33; ++$c) {
	    my $v = ($a*$b*$base)/$c;
	    my $e = $target - $v;
	    $e = -$e if $e < 0;
	    if ($e < $r[0] && ($lessthan == 0 || $v <= $target)) {
		@r = ( $e, $a, $b, $c, $v );
		print "$v @r\n";
	    }
	} 
    }
}

print " @r\n";
